package com.example.demo.mybatis;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.Reader;
import java.util.Arrays;
import java.util.List;

public class MybatisHelloWorld {

    public static void main(String[] args) {
        String path = "Configuration.xml";
        try {
            Reader resourceAsReader = Resources.getResourceAsReader(path);
            SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(resourceAsReader);
            SqlSession sqlSession = sessionFactory.openSession();
            List<Object> objectList;
            try {
                objectList = sqlSession.selectList("com.example.demo.mapper.AdminMapper.selectByRequestNo", "11066");
                System.out.println(Arrays.toString(objectList.toArray()));
            } finally {
                sqlSession.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
